{{Strip}}
{{- $ident := call $.Func.ProjectIdent -}}
<ul class="nav navbar-nav" id="topnav" data-project="{{$ident}}">

{{- $foundKey := ProjectSearchIdent $ident -}}
{{- range $key,$project := Projects -}}
{{- if and $project (call $.Func.HasNavigate $project.NavList) -}}
  <li{{if eq $key $foundKey}} class="active"{{end}} data-project="{{$project.GetIdent}}"><a href="{{BackendURL}}{{$project.GetURL}}" data-project="{{$project.GetIdent}}"><i class="fa fa-dashboard"></i> {{$project.GetName|$.T|UpperCaseFirst}}</a></li>
{{- end -}}
{{- end -}}

{{- $topNavigate := call $.Func.Navigate "top" -}}
{{- range $key, $nav := $topNavigate -}}
{{- if and $nav $nav.Display -}}
  <li class="dropdown">
  {{- if $nav.Children -}}
    <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
      <i class="fa fa-{{$nav.Icon|Default `gear`}}"></i>
      {{$nav.Name|$.T|UpperCaseFirst}}
      {{if $nav.Badge}}<sup class="badge badge-sm badge-danger">{{$nav.Badge}}</sup>{{end}}
      <b class="caret"></b>
    </a>

    {{- $groups := $nav.GetGroups `backend.top` -}}
    {{- if $groups -}}
    <ul class="dropdown-menu col-menu-2 from-top">
      {{- range $gk,$gv:=$groups -}}
      {{- if and (gt $gk 0) (eq (Math "mod" $gk 2) (Float64 0)) -}}
      <li class="col-sm-12 no-padding"></li>
      {{- end -}}
      {{- $.Set `partial.topnav.children` (MakeMap `nav` $nav `group` $gv) -}}
      {{Include "topnav_children" $}}
      {{- end -}}
    </ul>
    {{- else -}}
    <ul class="dropdown-menu from-top">
      {{- range $k, $c := $nav.Children -}}
      {{- if and $c $c.Display -}}
      <li>
        <a{{if eq $c.Target `ajax`}} href="javascript:;" data-ajax-url="{{BackendURL}}/{{$nav.Action}}{{if $c.Action}}/{{$c.Action}}{{end}}"{{else}} href="{{BackendURL}}/{{$nav.Action}}{{if $c.Action}}/{{$c.Action}}{{end}}"{{if ne $c.Target `redirect`}} data-pjax="#main-container" data-keepjs="true" data-marknav="top"{{end}}{{end}}{{range $ai,$av:=$c.Attributes}} {{$av.K|ToHTMLAttr}}="{{$av.V}}"{{end}}>
          {{- if eq $c.Icon "plus" -}}
          <span class="label label-primary pull-right">+</span>
          {{- end -}}
          {{- $c.Name|$.T|UpperCaseFirst -}}
          {{if $c.Badge}}<sup class="badge badge-sm badge-danger">{{$c.Badge}}</sup>{{end}}
        </a>
      </li>
      {{- end -}}
      {{- end -}}
    </ul>
    {{- end -}}

  {{- else -}}
    <a{{if eq $nav.Target `ajax`}} href="javascript:;" data-ajax-url="{{BackendURL}}/{{$nav.Action}}"{{else}} href="{{BackendURL}}/{{$nav.Action}}"{{if ne $nav.Target `redirect`}} data-pjax="#main-container" data-keepjs="true" data-marknav="true"{{end}}{{end}}{{range $ai,$av:=$nav.Attributes}} {{$av.K|ToHTMLAttr}}="{{$av.V}}"{{end}}>
      <i class="fa fa-{{$nav.Icon|Default `gear`}}"></i>
      {{$nav.Name|$.T|UpperCaseFirst}}
      {{if $nav.Badge}}<sup class="badge badge-sm badge-danger">{{$nav.Badge}}</sup>{{end}}
      <b class="caret"></b>
    </a>
  {{- end -}}
  </li>
  {{- end -}}
  {{- end -}} 
</ul>
{{/Strip}}